<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>	
<%@ include file="/pub/headmeta.jsp" %>
</head>
<body class="edit-bgr-color">
	<div class="right-head"><span class="right-head-font">修改用户</span></div>
	<div align="center" style="width: 98%">	
		<form id="editForm" method="post">	
			<input type="hidden" name="userId" value="${user.userId}"/>		
			<table cellpadding="5" style="width: 600px; font-size: 12px;">
				<tr>
					<td width="35%" align="right">帐号：</td>
					<td width="65%" align="left">${user.account}</td>					
				</tr>
				<tr>
					<td align="right">角色：</td>
					<td align="left"><select name="roleId" id="roleId" style="width: 60%"></select></td>					
				</tr>
				<tr>
					<td align="right">昵称：</td>
					<td align="left"><input type="text" name="name" id="name" style="width: 60%" value="${user.name}"/></td>					
				</tr>			
			</table>
			<div class="edit-line"></div>
			<input  type="button" class="button-1" value="修改" onclick="doEdit();"/>
			<input  type="button" class="button-1" value="重置" onclick="resetEx(this.form);loadData();"/>						
			<input  type="button" class="button-1" value="返回" onclick="back();"/>
		</form>
	</div>
</body>
</html>
<script type="text/javascript">
<!--
var roles=new Array();
//自动调用初始化
$(document).ready(function(){	
	//获取角色
	var url="${ctx}/role!getList.action?page=1&pageSize=100";
	$.ajax({type : "post", url : url, data : '', async : false, 
		success : function callback(txt){   
			var json = $.parseJSON(txt);			
			if (json.code==0) {	
				roles=json.info;	
				for(var n in roles){
					$("#roleId").append("<option value='"+roles[n].roleId+"'>"+roles[n].name+"</option>"); 
				}
			}else{
				alert('查询失败！');
			}
		}
	});

	
	loadData();
});
//初始化
function loadData(){	
	$("#roleId option[value='${user.roleId}']").attr("selected","true");
}

//修改
function doEdit() {
	var form=$("#editForm");
	form.attr("action","${ctx}/user!edit.action"); 
	form.submit();	
}

//返回
function back(){
	location.href="${ctx}/user!viewList.action";
}

//-->
</script>
